package com.hzqy.web.ac.epg;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.apache.ibatis.annotations.Select;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hzqy.service.epg.AcBFRecordServiceBean;
import com.hzqy.service.epg.AcSignServiceBean;
import com.hzqy.web.login.SessionKey;
import com.hzqy.web.vo.AcWinningVo;
import com.hzqy.web.vo.epg.AcBFRecordVo;

@Controller
@RequestMapping("/")
public class AcBFRecordAction {
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	@Resource
	private AcBFRecordServiceBean acRecordBean;
	
	/**
	 * 查询用户当期当天有没有竞猜
	 * @param acrecord
	 * f_ar_periods 当前期数  f_ar_activityid 活动id
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "/record/selectBFRecord")
	@ResponseBody
	public Object selectBFRecord(AcBFRecordVo acrecord, HttpSession session) {
		Map<String, Object> map = new HashMap<String, Object>();
		String userid= String.valueOf( session.getAttribute(SessionKey.SESSION_SERVERID));
		acrecord.setF_ar_serverid(userid);
		map = acRecordBean.selectAcBFRecord(acrecord);
		return map;
	}
	
	/**
	 * 插入用户竞猜数据
	 * @param acrecord
	 * f_ar_activityid 活动id  f_ar_phone 用户电话号码 f_ar_target 竞猜目标
	 * @param session
	 * @return
	 */
	@RequestMapping(value = "/record/insertBFRecord")
	@ResponseBody
	public Object insertBFRecord(AcBFRecordVo acrecord, HttpSession session) {
		Map<String, Object> map = new HashMap<String, Object>();
		String userid= String.valueOf( session.getAttribute(SessionKey.SESSION_SERVERID));
		acrecord.setF_ar_serverid(userid);
		map = acRecordBean.insertAcBFRecordBy(acrecord);
		return map;
	}

	/**戏曲答题使用
	 * f_ar_serverid ;//业务帐号
	 * f_ar_activityid ;//活动编号
	 * f_ar_name ;//活动名称
	 * f_ar_phone;//默认设为0
	 * f_ar_type;//默认设为3
	 * f_ar_target;//默认设为null
	 * f_ar_periods;//记录每次答题成绩
	 * rownum;//排名
	 * count;//总次数
	 * type;//查询类型 1:按月统计，2:按季统计
	 */
	/**
	 * 查询用户答题记录
	 * f_ar_activityid  活动编号
	 * f_ar_cdate ;//创建时间
	 */
	@RequestMapping("/opera/selectRecordByDate")
	@ResponseBody
	public Object selectRecordByCdate(AcBFRecordVo acBFRecordVo, HttpSession session) {
		String userid= String.valueOf(session.getAttribute(SessionKey.SESSION_SERVERID));
		acBFRecordVo.setF_ar_serverid(userid);
    	List<AcBFRecordVo> list = acRecordBean.selectByCdate(acBFRecordVo);
		return list;
	}
	/**
	 * f_ar_activityid  活动编号
	 * f_ar_periods  答题成绩
	 */
	@RequestMapping(value = "/opera/insertRecord")
	@ResponseBody
	public Object insertRecord(AcBFRecordVo acrecord, HttpSession session) {
		Map<String, Object> map = new HashMap<String, Object>();
		String userid= String.valueOf( session.getAttribute(SessionKey.SESSION_SERVERID));
		acrecord.setF_ar_serverid(userid);
		acrecord.setF_ar_name("戏曲答题活动");
		acrecord.setF_ar_phone("0");
		acrecord.setF_ar_type("3");
		map = acRecordBean.insertRecord(acrecord);
		return map;
	}
	/**
	 * 查询用户积分列表
	 * f_ar_activityid  活动编号
	 * f_ar_cdate ;//创建时间
	 */
	@RequestMapping("/opera/selectUserCount")
	@ResponseBody
	public Object selectUserCount(AcBFRecordVo acBFRecordVo,int startNow,int pageSize, HttpSession session) {
    	List<AcBFRecordVo> list = acRecordBean.selectCount(acBFRecordVo,startNow,pageSize);
		return list;
	}
}
